package Homework0816;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.Scanner;

public class Test02 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);

        System.out.println("name:");
        String name=sc.nextLine();
        System.out.println("pwd");
        String pwd=sc.nextLine();
        System.out.println("nick");
        String nick=sc.nextLine();
        System.out.println("age");
        int age=sc.nextInt();

        User user=new User(name,pwd,nick,age);
        File file = new File("./user.obj");
        try(
                FileOutputStream fos=new FileOutputStream(file);
            ObjectOutputStream oos=new ObjectOutputStream(fos))
        {
            oos.writeObject(user);
            System.out.println("register");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
